<?php
/**
 * Description of AdminLoginView
 *
 * @author Animus Inc.
 */

// Restrict Unrestricted Access

defined("_dispatch") or	die("Access Denied !");

// Constants

define('DOMROOT', dirname(dirname(__FILE__)));

// Imports

require_once DOMROOT.'/dependencies/lib/Twig/Autoloader.php';
require_once DOMROOT.'/classes/abstract/View.php';
require_once DOMROOT.'/forms/AdminLoginForm.php';

class AdminLoginView extends View{   
    private $_loginForm;
    private $_template;
    private $_attributes;
    
    public function __construct() {
        $this->_loginForm = new AdminLoginForm();
        Twig_Autoloader::register();// Starting and configuring the Twig templating engine
        $loader = new Twig_Loader_Filesystem(DOMROOT.'/templates');
        $twig = new Twig_Environment($loader, array('cache' => DOMROOT.'/compilation_cache','auto_reload' => TRUE ));
        $this -> _template = $twig ->loadTemplate('adminlogin.html');
        return true; 
    }

    public function output(){
        $this->_template -> display(array(
                                     'pageTitle' => 'Stockworldmarket - Admininstration',
                                     'adminLoginForm' => $this->_loginForm->renderAsTable(),
                                     'menubar' => '<a href="/stockworldmarket/new-user/register.php">Register</a>
                                              <a href="/stockworldmarket/admin/">Admin Login</a>'
                                     ));
        return true;
    }
    
    public function setLoginForm(Form $_form){
        $this->_loginForm = $_form;
        return true;
    }
    
    public function getLoginForm(){
        return $this->_loginForm;
    }
    
    public function setFormFieldValue($field_name,$value){
        $this->_loginForm->setFieldValue($field_name, $value);
        return true;
    }
    
    public function setAttributes($attributes){
        $this->_attributes = $attributes;
        return true;
    }
    
    public function getAttributes(){
        return $this->_attributes;
    }

    public function setViewData($attributes){
        $this->_attributes = $attributes;
        return true;
    }
    
    public function getViewData(){
        return $this->_attributes;
    }    
}
?>
